using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Xml;

using miciv;
using micivCore.Components;

namespace micivCore.Data
{
    public class MapTileManager : HashtableManager<string, MapTileDefinition>
    {
        protected CoreContext m_coreContext;

        public MapTileManager(CoreContext _coreContext)
        {
            this.m_coreContext = _coreContext;
        }

        public MapTileDefinition LoadTile(string _strLocation, CoMapProto _mapProto)
        {
            if (null == this.Get(_strLocation))
            {
                CoreManager coreManager = this.m_coreContext.CoreManager;
                XmlDocument xmlDoc = coreManager.LoadXml(_strLocation, false);
                MapTileDefinition mapTile = new MapTileDefinition(this.m_coreContext);
                if (false != mapTile.Initialize(xmlDoc.DocumentElement.SelectSingleNode("tile") as XmlElement))
                {
                    this.Add(_strLocation, mapTile);
                }
            }
            return this.Get(_strLocation);
        }
    }
}
